/**
 * Copyright (c) 2017,安徽皖通科技股份有限公司 All rights reserved.
 * @data:2017年10月17日
 * @author:MaShibo
 */
package com.wttech.dzzf.process.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import cn.com.taiji.sdk.model.comm.protocol.valid.VehiclePlateCheckValidateRequest;

/**
 * 车牌验证Dao实现
 * 
 * @date 2017年10月17日
 * @author MaShibo
 */
@Repository
public class VehicleValidInfoDao {
    
    
    @Resource(name = "jdbcTemplate")
    private JdbcTemplate testJdbcTemplate;
    
    public Integer queryVehicleInfosNum() {
        return testJdbcTemplate.queryForObject("SELECT COUNT(1) FROM BS_VEHICLE ", Integer.class);
    }
    
    public List<VehiclePlateCheckValidateRequest> queryVehicleValidReqInfos(int startRow, int endRow) {
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT * ");
        sql.append("   FROM (SELECT A.ID AS VEHICLEPLATE, A.TYPE AS VEHICLETYPE, ROWNUM AS RM ");
        sql.append("           FROM BS_VEHICLE A) ");
        sql.append("  WHERE RM >= ? ");
        sql.append("    AND RM <= ? ");
        return testJdbcTemplate.query(sql.toString(), new Object[] { startRow, endRow },
                BeanPropertyRowMapper.newInstance(VehiclePlateCheckValidateRequest.class));
    }
}
